package com.study.elasticsearchstudy.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ElasticSearchConfig {

    @Bean
    public RestHighLevelClient restHighLevelClient (){
        // RestClient.builder()入参是可变参数,如果是集群传入多个httpHost
        RestClientBuilder builder = RestClient.builder(new HttpHost("192.168.56.101",9200));
        return new RestHighLevelClient(builder);
    }

}
